
new Vue({
    el:'#main',
    data:{
        pageInfo:{},
        account:{
            accountStatus:""
        },
        isParam:false
    },
    methods:{
        selectPage:function (pageNum,PageSize) {
            let params = this.account;
            if (!this.isParam){
                this.account={
                    accountStatus:""
                }
            }
            axios({
                url: `manager/account/selectPage/${pageNum}/${PageSize}`,
                params: this.account
            }).then(response =>{
                this.pageInfo = response.data.obj;
                this.account = params ;
            })
        },
        selectPageAndParams:function () {
            this.isParam = true;
            this.selectPage(1,this.pageInfo.pageSize)

        },
        showDetail:function (aid) {
            layer.aid = aid;
            layer.open({
                type:2,
                title:false,
                shade:0.8,
                shadeClose: false,
                area:['80%','80%'],
                content:'manager/account/showDetail'
            })

        },
        doPause:function (aid,status) {
            if (status == '1'){
                layer.msg("该账户已经暂停使用");
                return;
            }
            if (status == '2'){
                layer.msg("该账户已经删除");
                return;
            }
            layer.msg('确定暂停该账户？',{
                btn: ['确定', '我再想想'],
                yes:()=>{
                    axios({
                        url: `manager/account/doPause/${aid}`,
                    }).then(response =>{
                        layer.msg(response.data.msg);
                        this.selectPage(1,this.pageInfo.pageSize)
                    }).catch(error=>{
                        layer.msg(error.msg)
                    })
                }
            })

        },
        doDelete:function (aid,status) {
            if (status == '2'){
                layer.msg("该账户已经删除");
                return;
            }
            layer.msg('确定停用该账户？',{
                btn: ['确定', '我再想想'],
                yes:()=>{
                    axios({
                        url: `manager/account/doDelete/${aid}`,
                    }).then(response =>{
                        layer.msg(response.data.msg);
                        this.selectPage(1,this.pageInfo.pageSize)
                    }).catch(error=>{
                        layer.msg(error.msg)
                    })
                }
            })
        },
        toInsert:function () {
            layer.message=''
            layer.open({
                type:2,
                title:false,
                shade:0.8,
                shadeClose: false,
                area:['80%','80%'],
                content:'manager/account/toInsert',
                end:()=>{
                    if (layer.message !=''){
                        layer.msg(layer.message+'');
                        this.selectPage(1,this.pageInfo.pageSize)
                    }

                }
            })

        },
        toUpdate:function (aid,status) {
            if (status == '2'){
                layer.msg("该账户已经删除,不能修改");
                return;
            }
            layer.aid = aid;
            layer.message='';
            layer.open({
                type:2,
                title:false,
                shade:0.8,
                shadeClose: false,
                area:['80%','80%'],
                content:'manager/account/toUpdate',
                end:()=>{
                    if (layer.message!=''){
                        layer.msg(layer.message+'');
                        this.selectPage(1,this.pageInfo.pageSize)
                    }

                }
            })

        }

    },
    created:function () {
        this.selectPage(1,5);
    }

})